{{- $lightgallery := .Page.Params.lightgallery | default site.Params.Page.lightgallery | default false -}}
{{- $optim := slice 
    (dict "Process" "resize 800x webp q75" "descriptor" "800w")
    (dict "Process" "resize 1200x webp q75" "descriptor" "1200w")
    (dict "Process" "resize 1600x webp q75" "descriptor" "1600w")
-}}

{{- if .Title -}}
<figure>
    {{- dict "Src" .Destination "Title" .Text "Caption" .Title "Linked" $lightgallery "Loading" "lazy" "Resources" .Page.Resources "OptimConfig" $optim | partial "plugin/image.html" -}}
    <figcaption class="image-caption">
        {{- .Title | safeHTML -}}
    </figcaption>
</figure>
{{- else -}}
    {{- dict "Src" .Destination "Class" "tw-inline" "Title" .Text "Caption" .Title "Loading" "lazy" "Resources" .Page.Resources "OptimConfig" $optim | partial "plugin/image.html" -}}
{{- end -}}

